package com.heyi.saas.start.service;

import com.heyi.saas.start.properties.TenantTableProperties;
import com.heyi.saas.start.vo.TenantTable;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * @author dengfeng
 * @Description: 租户隔离表
 * @date 2021/8/1018:05
 */
public class TenantTables {

    private List<String> tenantTableList = new ArrayList<>();
    private List<Boolean> includeSharingList = new ArrayList<>();

    public void setTenantTables(TenantTableProperties tenantTableProperties){
        for (TenantTable table: tenantTableProperties.getTableList()) {
            tenantTableList.add(table.getName());
            includeSharingList.add(table.isShared());
        }
    }

    public void add(String tableName, boolean includeSharing) {

        tenantTableList.add(tableName);
        includeSharingList.add(includeSharing);
    }

    public String getTableName(int index){
        return tenantTableList.get(index);
    }

    public Boolean getIncludeSharing(int index){
        return includeSharingList.get(index);
    }

    public List<String> getTenantTableList(){
        return tenantTableList;
    }
}
